{% extends 'admin_base.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<div class="row">
  <div class="col-12">
    <div class="card">
        <div class="card-header">
          <h3 class="card-title">{% translate "Items that will never be triggered" %}</h3>
        </div>
        <div class="card-body">
          {% for condition in conditions %}

            {# FOR NEW HIRES #}
            {% if condition.external_new_hire|length or condition.to_do.all|length or condition.preboarding.all|length or condition.badges.all|length or condition.integration_configs.all|length or condition.resources.all|length or condition.introductions.all|length %}
            <span class="badge bg-azure mb-2">{% translate "new hire" %}</span>
            {% endif %}
            {% for item in condition.preboarding.all %}
              {% include '_condition_line_item.html' with type='preboarding' read_only=True %}
            {% endfor %}
            {% for item in condition.appointments.all %}
              {% include '_condition_line_item.html' with type='appointment' read_only=True %}
            {% endfor %}
            {% for item in condition.external_new_hire %}
              {% if item.send_via == ExternalMessageType.EMAIL %}
                {% include '_condition_line_item.html' with type='pendingemailmessage' read_only=True %}
              {% elif item.send_via == ExternalMessageType.SLACK %}
                {% include '_condition_line_item.html' with type='pendingslackmessage' read_only=True %}
              {% else %}
                {% include '_condition_line_item.html' with type='pendingtextmessage' read_only=True %}
              {% endif %}
            {% endfor %}
            {% for item in condition.to_do.all %}
              {% include '_condition_line_item.html' with type='todo' read_only=True %}
            {% endfor %}
            {% for item in condition.resources.all %}
              {% include '_condition_line_item.html' with type='resource' read_only=True %}
            {% endfor %}
            {% for item in condition.introductions.all %}
              {% include '_condition_line_item.html' with type='introduction' read_only=True %}
            {% endfor %}
            {% for item in condition.badges.all %}
              {% include '_condition_line_item.html' with type='badge' read_only=True %}
            {% endfor %}
            {% for item in condition.integration_configs.all %}
              {% include '_condition_line_item.html' with type='integrationconfig' provision_created=1 read_only=True %}
            {% endfor %}

            {# FOR ADMINS #}
            {% if condition.external_admin|length or condition.admin_tasks.all|length %}
            <span class="badge bg-orange mb-2">{% translate "admins" %}</span>
            {% endif %}
            {% for item in condition.admin_tasks.all %}
              {% include '_condition_line_item.html' with type='pendingadmintask' read_only=True %}
            {% endfor %}
            {% for item in condition.external_admin %}
              {% if item.send_via == ExternalMessageType.EMAIL %}
                {% include '_condition_line_item.html' with type='pendingemailmessage' read_only=True %}
              {% elif item.send_via == ExternalMessageType.SLACK %}
                {% include '_condition_line_item.html' with type='pendingslackmessage' read_only=True %}
              {% else %}
                {% include '_condition_line_item.html' with type='pendingtextmessage' read_only=True %}
              {% endif %}
            {% endfor %}

            {% include "_trigger_sequence_items.html" %}

            {% if condition != conditions.last %}
              <div class="hr-text">{% translate "Condition" %}</div>
            {% endif %}
          {% endfor %}
        </div>
        <div class="card-footer">
          {% if employee.is_new_hire %}
            <a href="{% url 'people:new_hire' employee.id %}" class="btn btn-primary" style="float: right">{% translate "Go to new hire" %}</a>
          {% else %}
            <a href="{% url 'people:offboarding-detail' employee.id %}" class="btn btn-primary" style="float: right">{% translate "Go to employee" %}</a>
          {% endif %}
        </div>
    </div>
  </div>
</div>
{% endblock %}
